{% extends "book/template.html" %}

{% block container %}
    <div class="row">
        <div class="page-header ">
            <div class="col-sm-8 col-sm-offset-1 col-md-10 col-md-offset-1 main">
                <!-- 面板开始 -->
                <div class="panel panel-primary">
                    <div class="panel-heading"><h3 class="panel-title">查看书籍</h3></div>
                    <div class="panel-body">
                        <!--表格 工具栏 开始-->
                        <div class="row table-toolbar">
                            <div class="col-md-3 col-sm-6">
                                <form action="">
                                <div class="input-group">
                                    <input name="q" type="text" class="form-control" placeholder="Search for...">
                                    <span class="input-group-btn"><button class="btn btn-default" type="submit">搜索</button></span>
                                </div>
                                </form>
                            </div>
                        </div>
                        <br>
                        <!--表格 工具栏 结束-->
                        <table class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>书籍名称</th>
                                    <th>作者</th>
                                    <th>价格</th>
                                    <th>出版社</th>
                                    <th>出版日期</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            {% for book in book %}
                                <tr>
                                    <td>{{ forloop.counter }}</td>
                                    <td>{{ book.title }}</td>
                                    <td>
                                        {% for author in book.authors.all %}
                                            <span>{{ author.name }}</span>
                                            {% if not forloop.last %}
                                            ,
                                            {% endif %}
                                        {% endfor %}
                                    </td>
                                    <td>{{ book.price}}</td>
                                    <td>{{ book.publish.name}}</td>
                                    <td>{{ book.pub_date}}</td>
                                    <td class="text-center">
                                        <a class="btn btn-info btn-sm" href="/edit_book/{{ book.id }}"><i
                                            class="fa fa-pencil fa-fw" aria-hidden="true"></i>编辑
                                        </a>
                                        <a class="btn btn-danger btn-sm" href="/del_book/?id={{ book.id }}"><i
                                            class="fa fa-trash-o fa-fw"
                                            aria-hidden="true"></i>删除
                                        </a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                            <!--分页 开始-->
                            <div>
                                <nav aria-label="Page navigation" class="pull-right">
                                    <ul class="pagination">
                                        {{ pagination.page_html|safe }}
                                    </ul>
                                </nav>
                            </div>
                            <!--分页 结束-->
                        </div>
                    </div>
                    <!-- 面板 结束-->
                </div>
        </div>
    </div>
{% endblock container %}